# 打印菱形
def print_diamond(n):
    for i in range(n):
        print(' ' * (n - i - 1) + '*' * (2 * i + 1))
    for i in range(n - 2, -1, -1):
        print(' ' * (n - i - 1) + '*' * (2 * i + 1))
print_diamond(5)
# 打印水仙花数
def is_armstrong_number(n):
    num_str = str(n)
    num_digits = len(num_str)
    sum_of_digits = sum(int(digit) ** num_digits for digit in num_str)
    return n == sum_of_digits
for i in range(100, 1000):
    if is_armstrong_number(i):
        print(i)
# 打印九九乘法表
for i in range(1, 10):
    for j in range(1, i + 1):
        print("%d * %d = %d" % (j, i, i * j), end="\t")
    print()
# 打印完数
def is_perfect_number(n):
    sum = 0
    for i in range(1, n):
        if n % i == 0:
            sum += i
    return sum == n
def print_perfect_numbers(n):
    for i in range(1, n+1):
        if is_perfect_number(i):
            print(i)
    return
print_perfect_numbers(100)
# 打印斐波那契数列
def Fibonacci(n):
    if n < 1:
        return
    if n == 1:
        return 0
    if n == 2:
        return 1
    return Fibonacci(n - 1) + Fibonacci(n - 2)
for i in range(1, 10):
    print(Fibonacci(i))